import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class User {
    private String name;
    private int identity;//买家0还是卖家1

    public void browse() {
        System.out.println(this.name + "浏览了电动车");
        BicycleList bicycleList = BicycleList.GetBicycleList();
        BicycleList.display();
    }

    public void post(Group group) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("type：");
        String type = scanner.nextLine();
        System.out.print("priceBefore：");
        float priceBefore = scanner.nextLine();
        System.out.print("priceSell：");
        float priceSell = scanner.nextLine();
        System.out.print("condition:");
        String condition = Float.parseFloat(scanner.nextLine());
        System.out.print("places：");
        String places = scanner.nextLine();
        Bicycle bicycle=new Bicycle(type,priceBefore,priceSell,condition,places);
        BicycleList bicycleList = BicycleList.GetBicycleList();
        bicycleList.add(bicycle);
        System.out.println("用户" + this.name + "发布了一辆电驴：" + bicycle);
        group.NotifyUser(this.name, bicycle.getType());
    }

    public void NotifyUser(String username, String title) {
        System.out.println(this.userName + "用户：" + username + "发布了一辆电驴：" + title);
        //遍历观察者集合，调用每一个用户（自己除外）的围观方法
        for (User user : users) {
            if (!user.getName().equals(username)) {
                user.onlook();
            }
        }
    }

public void onlook() {
        System.out.println(this.name+" 快来围观吧！");
    }
    public String getName() {
        return name;
    }

    public User() {
    }

    public User(String name) {
        this.name = name;
    }
}
